<?php
namespace Home\Controller;
use Think\Controller;
class CommentController extends BaseController {
    //崔晓真 评论列表
    public function commentlist(){
        $admin=M('admins');
        $admins=$admin->find();
        $this->admin=$admins;
        
       $commentmodel = M('comments as c')->join('user as u on u.user_id=c.user_id');
       $this->comment=$commentmodel->select();
       $this->display();
    }

    // 崔晓真 删除晒图
    public function delete($comment_id){
        $admin=M('admins');
        $admins=$admin->find();
        $this->admin=$admins;

        $commentsmodel=M('comments');
        $res=$commentsmodel->where("comment_id=$comment_id")->find();
        // $photoPath = realpath("./Public/upload/commentpic/".$res['photo']);
        // unlink($photoPath);
        //$res=$usersmodel->where("id=$id")->delete();
        if ($commentsmodel->delete($comment_id)) {
            $this->success('删除成功！');
        } else {
                $this->error('删除失败');
        }
    }

}